<?php
	
	$this->apploadlib("lib/accounts.lib.php", "kleoaccounts", $users);

	if(!$users->is_logged()){
		if(is_file(KLEO_FULL_TEMPLATE_ROUTE.'users/loginbox.tpl')){
			$this->tpl_load('users/loginbox.tpl', $lbuff);
		} else {
			$this->tpl_load('users/views/loginbox.tpl', $lbuff);
		}
		$this->tpl_set("ICON_THEME", KLEO_CURRENT_ICONS, $lbuff, $lbuff);
	} else {
		$uid = $_SESSION['uid'];
		$query = $this->query("SELECT * FROM ".KLEO_TABLE_PREFIX."users_profiles WHERE uid = $uid LIMIT 1");
		while($row = $this->fetch_array($query)){
			$avatar = $row['avatar'];
		}

		if(empty($avatar)){
			$avatar = 'default.png';
		}
		$users->get_group_name($uid, $groupname);
		$this->tpl_load(KLEO_MODULES_DIR.'users/views/userbox.tpl', $lbuff);
		$this->tpl_set("UBOX_USERNAME", $users->get_username($uid), $lbuff, $lbuff);
		$this->tpl_set("UBOX_PRIVILEGIES", $groupname, $lbuff, $lbuff);
		$this->tpl_set("AVATAR_URL", KLEO_SITEURL.'/media/avatars/'.$avatar, $lbuff, $lbuff);
		if($groupname == 'admin' OR $groupname == 'chuck'){
			$this->tpl_set("ADMIN_PANNEL", '<li><a href="index.php?module=admin">Admin Pannel</a></li>', $lbuff, $lbuff);
		} else {
			$this->tpl_set("ADMIN_PANNEL", "", $lbuff, $lbuff);
		}
	}

	$this->compile($lbuff, $lbuff);
	$output = $lbuff;

?>
